<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
  <meta name="description" content="">
  <meta name="author" content="">
  <link rel="icon" href="../../favicon.ico">

  <title>酷桃木</title>
  <!-- Bootstrap core CSS -->
  <link href="./static/css/bootstrap.min.css" rel="stylesheet">

  <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
  <link href="./static/css/ie10-viewport-bug-workaround.css" rel="stylesheet">

  <!-- Custom styles for this template -->
  <link href="./static/css/dashboard.css" rel="stylesheet">

  <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
  <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
  <script src="./static/js/ie-emulation-modes-warning.js"></script>

  <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
  <!--[if lt IE 9]>
      <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>

  <nav class="navbar navbar-inverse navbar-fixed-top">
    <div class="container-fluid">
      <div class="navbar-header">
        <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"
          aria-expanded="false" aria-controls="navbar">
          <span class="sr-only">Toggle navigation</span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
          <span class="icon-bar"></span>
        </button>
        <a class="navbar-brand" href="#">Flowing</a>
      </div>
      <div id="navbar" class="navbar-collapse collapse">
        <ul class="nav navbar-nav navbar-right">
          <li><a href="#">Dashboard</a></li>
          <li><a href="#">Settings</a></li>
          <li><a href="#">Profile</a></li>
          <li><a href="#">Help</a></li>
        </ul>
        <form class="navbar-form navbar-right">
          <input type="text" class="form-control" placeholder="Search...">
        </form>
      </div>
    </div>
  </nav>

  <div class="container-fluid">
    <div id="template_show" class="row">
      <div class="col-sm-3 col-md-2 sidebar">
        <ul class="nav nav-sidebar">
          <li class="active"><a href="#">服务器监控 <span class="sr-only">(current)</span></a></li>
          <li><a href="#">图表</a></li>
          <li><a href="#">Analytics</a></li>
          <li><a href="#">Export</a></li>
        </ul>
        <!-- <ul class="nav nav-sidebar">
            <li><a href="">Nav item</a></li>
            <li><a href="">Nav item again</a></li>
            <li><a href="">One more nav</a></li>
            <li><a href="">Another nav item</a></li>
            <li><a href="">More navigation</a></li>
          </ul>
          <ul class="nav nav-sidebar">
            <li><a href="">Nav item again</a></li>
            <li><a href="">One more nav</a></li>
            <li><a href="">Another nav item</a></li>
          </ul> -->
      </div>
      <!--templpate -->

    </div>
  </div>

  <!-- Bootstrap core JavaScript
    ================================================== -->
  <!-- Placed at the end of the document so the pages load faster -->
  <script src="./static/js/jquery.min.js"></script>
  <script>window.jQuery || document.write('<script src="./static/js/jquery.min.js"><\/script>')</script>
  <script src="./static/js/bootstrap.min.js"></script>
  <!-- Just to make our placeholder images work. Don't actually copy the next line! -->
  <script src="./static/js/holder.min.js"></script>
  <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
  <script src="./static/js/ie10-viewport-bug-workaround.js"></script>
</body>
<script src="https://cdn.staticfile.org/echarts/4.3.0/echarts.min.js"></script>
<script src="./static/js/fw4websocket.js"></script>
<script src="./static/js/template-native.js"></script>
<script>
  function init(option, id) {
    var chartDom = document.getElementById(id);
    var myChart = echarts.init(chartDom);
    option && myChart.setOption(option);
  }
  function show(a) {
    var str = '类别:';
    return str.concat(
      a.name + '\n\n' + '次数:',
      a.value + '\n\n' + '占比:',
      ((a.value / 2010) * 100).toFixed(2) + '%'
    );
  }
  function s() {
    var ws = websocket("ws://local.taomu.cool:9310/fig/ws/socket");
    ws.open(function (evt) {
      ws.send('run', "Hello Run");
      ws.message(function (evt) {
        var data = JSON.parse(evt.data);
        console.log(data);
        data.data.tooltip.formatter = show;
        data.data.series[0].label.formatter = show;
        init(data.data, "container");
      });
    });
    setTimeout(s, 60 * 1000);
  }
  $(document).ready(function () {
    var temp = document.getElementsByTagName("template")[0];
    var item = temp.content.querySelector("div");
    var n = document.importNode(item, true);
    document.getElementById("template_show").appendChild(n);
    s();
  })
</script>
<template>
  <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
    <h1 class="page-header">图表</h1>
    <div id="main" class="panel panel-default" style="width:300px">
      <div id="container" style="height: 300px"></div>
    </div>
  </div>
</template>

</html>